package com.yjd.bi.depository.service.impl;

import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;

import com.yjd.comm.util.FrameUtil;
import org.springframework.stereotype.Service;

import com.yjd.comm.base.dao.IBaseDao;
import com.yjd.comm.base.service.impl.BaseServiceImpl;
import com.yjd.bi.depository.model.BasicDataDepoModel;
import com.yjd.bi.depository.service.IBasicDataDepoService;
import com.yjd.bi.depository.dao.IBasicDataDepoDao;

/**
 * <b>description</b>：银行存管数据统计业务实现<br>
 * <b>time</b>：2017-05-17 15:39:33 <br>
 * <b>author</b>：  yangchangyan@yijiedai.com
 */
@Service("basicDataDepoService")
public class BasicDataDepoServiceImpl extends BaseServiceImpl implements IBasicDataDepoService {

	/**
	 * 插入
	 * 
	 * @param model
	 * @return
	 * @throws Exception
	 */
	public BasicDataDepoModel insert(BasicDataDepoModel model) throws Exception {
		return this.basicDataDepoDao.insertModel(model, true);
	}

	/**
	 * 更新
	 * 
	 * @param model
	 * @return
	 * @throws Exception
	 */
	public int update(BasicDataDepoModel model) throws Exception {
		return this.basicDataDepoDao.updateModel(model, true);
	}

	/**
	 * 根据id删除
	 * 
	 * @param id
	 * @return
	 * @throws Exception
	 */
	public int delete(long id) throws Exception {
		Map<Object, Object> paramMap = new HashMap<Object, Object>();
		paramMap.put("id", id);
		return this.basicDataDepoDao.deleteModel(paramMap, true);
	}

	@Override
	public BasicDataDepoModel countByDatePeriod(Long beginDate, Long endDate) throws Exception {
		Map<Object, Object> paramMap = new HashMap<Object, Object>();
		paramMap.put("beginDate", beginDate);
		paramMap.put("endDate", endDate);
		return this.basicDataDepoDao.countByDatePeriod(paramMap);
	}

	@Override
	public int countDepoBankByYear(Integer start_year, Integer end_year) throws Exception {
		Map param = FrameUtil.newHashMap();
		if(start_year!=null){
			param.put("start_year",start_year);
		}
		if(end_year!=null){
			param.put("end_year",end_year);
		}
		return this.basicDataDepoDao.countDepoBankByYear(param);
	}

	@Resource
	private IBasicDataDepoDao basicDataDepoDao;

	@Override
	public IBaseDao getBaseDao() {
		return this.basicDataDepoDao;
	}

}
